/**
 * file have open file Dialog & filter for opening only xml files
 */
package com.keggview.application.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.IWorkbenchWindow;

/**
 * @author Pablo
 *
 */
public class OpenFileAction extends Action {

	public static final String ID = "com.keggview.application.actions.OpenFileAction";
	
	private IWorkbenchWindow window;
	
	public OpenFileAction(IWorkbenchWindow window) {
		this.setId(OpenFileAction.ID);
		String description = "Otwiera plik mapy z bazy Kegg";
		this.window = window;
		this.setText("Otwórz");
		this.setToolTipText(description);
		this.setAccelerator(SWT.CTRL + 'O');
	}
	
	@Override
	public void run() {
		FileDialog fd = new FileDialog(window.getShell(), SWT.OPEN);
		String[] fNames = {"Mapy XML"};
		String[] fExt	= {"*.xml"};
		fd.setFilterNames(fNames);
		fd.setFilterExtensions(fExt);
		fd.setText("Otwórz mapę typu XML z bazy Kegg");
		fd.open();
	}
}
